package de.nordakademie.wpk.boerse.ui.handler;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.handlers.HandlerUtil;

import de.nordakademie.wpk.boerse.ui.view.UebersichtView;

public class UIRefreshHandler extends AbstractHandler {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
	 * ExecutionEvent)
	 */
	@Override
	public Object execute(final ExecutionEvent event) throws ExecutionException {
		Display.getDefault().asyncExec(new Runnable() {
			@Override
			public void run() {
				final IWorkbenchPage activePage = HandlerUtil
						.getActiveWorkbenchWindow(event).getActivePage();
				final UebersichtView view = (UebersichtView) activePage
						.findView(UebersichtView.ID);
				view.refresh();
			}
		});
		return null;
	}

}
